<template>
	<view class="item">
		<view class="top">
			<view class="info acea-row row-between row-middle">
				<view class="left acea-row">
					<image :src="item.avatar?item.avatar:'../static/images/f.png'" mode="aspectFill"></image>
					<view class="other acea-row row-column row-between">
						<text class="limit line1 col_gray">{{item.nickname}}</text>
						<text class="limit line1">{{item.phone}}</text>
					</view>
				</view>
				<view class="right acea-row row-middle">
					<text class="guan acea-row row-middle row-center"
						@click="change(item)">{{item.status==1?'已关注':'+关注'}}</text>
					<text class="chat acea-row row-middle row-center" @click="toChat">私聊</text>
				</view>
			</view>
			<view class="detail font22 col_80 line1">
				{{item.detail || ''}}
			</view>
		</view>
		<view v-if="item.title" @click="toLy" style="font-size: 24rpx;">
			来源: <text style="margin-left: 8rpx;color: red;">{{item.title }}</text>
		</view>
		<view class="middle acea-row row-between row-middle">
			<!-- 		 <view class="tipbox acea-row row-column row-middle row-between">
		 	<text class="col_red font32">286元</text>
		 	<text class="col_80 font24">消费返现累计</text>
		 </view> -->
			<view class="tipbox acea-row row-column row-middle row-between">
				<text class="col_orange font32">226个</text>
				<text class="col_80 font24">奖励金币</text>
			</view>
			<view class="tipbox acea-row row-column row-middle row-between">
				<text class="font32">{{item.ofDays}}天</text>
				<text class="col_80 font24">绑定</text>
			</view>
		</view>
		<view class="bottom acea-row row-middle row-between">
			<text class="col_gray font22">绑定时间：{{item.time}}</text>
			<text class="col_gray font22">最后登录：{{item.lastLoginTime}}</text>
		</view>
	</view>
</template>
<script>
	// +----------------------------------------------------------------------
	// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
	// +----------------------------------------------------------------------
	// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
	// +----------------------------------------------------------------------
	// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
	// +----------------------------------------------------------------------
	// | Author: CRMEB Team <admin@crmeb.com>
	// +----------------------------------------------------------------------
	import {
		addUserFriend,
		delUserFriend,
	} from '@/api/user.js'
	const app = getApp();
	export default {
		name: '',
		props: {
			item: Object
		},
		data() {
			return {

			}
		},
		methods: {
			toChat() {
				getApp().globalData.into_singleChatRoom({
					contactId:this.item.uid,
					phone:this.item.phone
				})
			},
			toLy(){
				/**
				 * 1租转、2二手、3商家服务、4供应链、5招工、6求租、7求购、8出售、9项目、10求职、11求购供应链
				 */
				let path = this.getPath()
				uni.navigateTo({
					url: path
				})
			},
			getPath() {
				let taskType = Number(this.item.type)
				if ([1,8].includes(taskType)) {
					return  '/pages/details/shopRent/shopRent?id='+this.item.infoId+'&storeCategory='+this.item.storeCategory+'&st='+(this.pigStatus)
				} else if ([6,7].includes(taskType)) {
					return '/pages/details/askRent/askRent?'+(this.item.buystoreId ? 'buystoreId=' : 'askrentId=') + this.item.infoId
				} else if (taskType == 5) {
					return '/pages/details/recruitWorkers/recruitWorkers?id='+this.item.infoId
				} else if (taskType == 3) {
					return '/pages/details/merchantService/merchantService?id='+this.item.infoId
				} else if (taskType == 2) {
					return '/pages/details/unused/unused?id='+this.item.infoId
				} else if (taskType == 6) {
					return '/pages/details/supplyChain/supplyChain?id='+this.item.infoId
				} else if (taskType == 10) {
					return '/pages/details/jobHunting/jobHunting?id='+this.item.infoId
				} else if (taskType == 11) {
					return '/pages/details/askSupply/askSupply?id='+this.item.infoId
				}
			},
			async change(item) {
				//关注/取关
				let res;
				if (item.status == 1) {
		
					res = await delUserFriend({
						uid: item.friendId,
						friendId: item.uid
					})
				} else {

					res = await addUserFriend({
						friendId: item.uid
					});
				}

				if (res.code === 200) {
					item.status = item.status == 1 ? 0 : 1
					this.$emit('reload');
				}

				return item;

			}
		}
	}
</script>

<style lang="scss" scoped>
	.item {
		background-color: #fff;
		color: #333;
		border-radius: 10rpx;
		margin-bottom: 28rpx;
		padding: 48rpx 30rpx 36rpx;
	}

	.col_red {
		color: #EE212D;
	}

	.col_gray {
		color: #BDBBBB;
	}

	.col_orange {
		color: #FF8D1A;
	}

	.col_80 {
		color: #808080;
	}

	.font20 {
		font-size: 20rpx;
	}

	.font22 {
		font-size: 22rpx;
	}

	.font24 {
		font-size: 24rpx;
	}

	.font32 {
		font-size: 32rpx;
	}

	.font28 {
		font-size: 28;
	}

	.limit {
		width: 200rpx;
	}

	.top {
		.info {
			image {
				width: 68rpx;
				height: 68rpx;
				border-radius: 34rpx;
				margin-right: 10rpx;
			}
		}
	}

	.guan,
	.chat {
		width: 166rpx;
		height: 63rpx;
		border-radius: 31rpx;
		font-size: 26rpx;
		color: #fff;
		background-color: #EE212D;
	}

	.guan {
		color: #EE212D;
		background-color: transparent;
		margin-right: 12rpx;
		border: 2rpx solid #EE212D;
	}

	.middle {
		height: 160rpx;
		margin-top: 20rpx;
		padding: 30rpx 30rpx;
		border-top: 2rpx solid #EEEEEE;
		border-bottom: 2rpx solid #EEEEEE;

		.tipbox {
			height: 100%;
		}
	}

	.detail {
		height: 36rpx;
		line-height: 36rpx;
		color: #BDBBBB;
		marign-bottom: 12rpx;
		word-break: break-all;
	}

	.bottom {
		margin-top: 30rpx;
	}
</style>